<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
      子序列其实就是子集，所以也不需要终止条件，每次进入递归都判断是否满足条件，满足推入res
       */
      var findSubsequences = function (nums) {
        let res = []
        let map = new Map()
        function backTracking(path, startIndex) {
          //需要确保递增，所以path.length>1
          if (path.length > 1) {
            let str = path.join(',')
            if (!map.has(str)) {
              map.set(str, str)
              res.push([...path])
            } else {
              return //剪枝
            }
          }
          for (let i = startIndex; i < nums.length; i++) {
            //从path数组中取出元素  因为nums从-100到100  不可以这么写。因为有0。。。
            if (path.length == 0 || nums[i] >= path[path.length - 1]) {
              path.push(nums[i])
              backTracking(path, i + 1)
              path.pop()
            }
          }
        }
        backTracking([], 0)
        return res
      }
      let n = 0 || -100
    </script>
  </body>
</html>
